
local 装备自选 = 多开数据[多开数据.当前].__UI界面.窗口层:创建我的窗口("装备自选",0,0,300,407)
local 当前=多开数据.当前
local 可用特技={"破血狂攻","弱点击破","凝气诀","凝神诀","冥王爆杀","慈航普度","绝幻魔音","诅咒之伤","气疗术","命疗术","回魂咒","移行换影","天衣无缝","心如明镜","气归术","命归术","水清诀","冰清诀","玉清诀","晶清诀","四海升平","破血狂攻","罗汉金钟","圣灵之甲","魔兽之印","野兽之力","放下屠刀","太极护法","光辉之甲","流云诀","笑里藏刀","破碎无双"}
local 可用特效={}
local 额外属性={"体质","魔力","力量","耐力","敏捷"}
local 可用点化 = {"定心术","变身"}
local 属性类型 = {"特技","特效","双加[1]","双加[2]"}
local 可选造型
local 可选特技1 = {}
local ansl = 2
local 待选 = {}
	待选[1] = {"红缨枪","曲尖枪","锯齿矛","乌金三叉戟","火焰枪","墨杆金钩","玄铁矛","金蛇信","丈八点钢矛","暗夜","梨花","霹雳","刑天之逆","五虎断魂","飞龙在天","天龙破城","弑皇"}
	待选[2] = {"青铜斧","开山斧","双面斧","双弦钺","精钢禅钺","黄金钺","乌金鬼头镰","狂魔镰","恶龙之齿","破魄","肃魂","无敌","五丁开山","元神禁锢","护法灭魔","碧血干戚","裂天"}
	待选[3] = {"青铜短剑","铁齿剑","吴越剑","青锋剑","龙泉剑","黄金剑","游龙剑","北斗七星剑","碧玉剑","鱼肠","倚天","湛卢","魏武青虹","灵犀神剑","四法青云","霜冷九州","擒龙"}
	待选[4] = {"双短剑","镔铁双剑","龙凤双剑","竹节双剑","狼牙双剑","鱼骨双剑","赤焰双剑","墨玉双剑","梅花双剑","阴阳","月光双剑","灵蛇","金龙双剪","连理双树","祖龙对剑","紫电青霜","浮犀"}
	待选[5] = {"五色缎带","幻彩银纱","金丝彩带","无极丝","天蚕丝带","云龙绸带","七彩罗刹","缚神绫","九天仙绫","彩虹","流云","碧波","秋水落霞","晃金仙绳","此最相思","揽月摘星","九霄"}
	待选[6] = {"铁爪","天狼爪","幽冥鬼爪","青龙牙","勾魂爪","玄冰刺","青刚刺","华光刺","龙鳞刺","撕天","毒牙","胭脂","九阴勾魂","雪蚕之刺","贵霜之牙","忘川三途","离钩"}
	待选[7] = {"折扇","铁骨扇","精钢扇","铁面扇","百折扇","劈水扇","神火扇","阴风扇","风云雷电","太极","玉龙","秋风","画龙点睛","秋水人家","逍遥江湖","浩气长舒","星瀚"}
	待选[8] = {"细木棒","金丝魔棒","玉如意","点金棒","云龙棒","幽路引魂","满天星","水晶棒","日月光华","沧海","红莲","盘龙","降魔玉杵","青藤玉树","墨玉骷髅","丝萝乔木","醍醐"}
	待选[9] = {"松木锤","镔铁锤","八棱金瓜","狼牙锤","烈焰锤","破甲战锤","震天锤","巨灵神锤","天崩地裂","八卦","鬼牙","雷神","混元金锤","九瓣莲花","鬼王蚀日","狂澜碎岳","碎寂"}
	待选[10] = {"牛皮鞭","牛筋鞭","乌龙鞭","钢结鞭","蛇骨鞭","玉竹金铃","青藤柳叶鞭","雷鸣嗜血鞭","混元金钩","龙筋","百花","吹雪","游龙惊鸿","仙人指路","血之刺藤","牧云清歌","霜陨"}
	待选[11] = {"黄铜圈","精钢日月圈","离情环","金刺轮","风火圈","赤炎环","蛇形月","子母双月","斜月狼牙","如意","乾坤","月光双环","别情离恨","金玉双环","九天金线","无关风月","朝夕"}
	待选[12] = {"柳叶刀","苗刀","夜魔弯刀","金背大砍刀","雁翅刀","破天宝刀","狼牙刀","龙鳞宝刀","黑炎魔刀","冷月","屠龙","血刃","偃月青龙","晓风残月","斩妖泣血","业火三灾","鸣鸿"}
	待选[13] = {"曲柳杖","红木杖","白椴杖","墨铁拐","玄铁牛角杖","鹰眼法杖","腾云杖","引魂杖","碧玺杖","业焰","玉辉","鹿鸣","庄周梦蝶","凤翼流珠","雪蟒霜寒","碧海潮生","弦月"}
	待选[14] = {"硬木弓","铁胆弓","紫檀弓","宝雕长弓","錾金宝弓","玉腰弯弓","连珠神弓","游鱼戏珠","灵犀望月","非攻","幽篁","百鬼","冥火薄天","龙鸣寒水","太极流光","九霄风雷","若木"}
	待选[15] = {"琉璃珠","水晶珠","珍宝珠","翡翠珠","莲华珠","夜灵珠","如意宝珠","沧海明珠","无量玉璧","离火","飞星","月华","回风舞雪","紫金葫芦","裂云啸日","云雷万里","赤明"}
	待选[16] = {"钝铁重剑","桃印铁刃","赭石巨剑","壁玉长铗","青铜古剑","金错巨刃","惊涛雪","醉浮生","沉戟天戊","鸦九","昆吾","弦歌","墨骨枯麟","腾蛇郁刃","秋水澄流","百辟镇魂","长息"}
	待选[18] = {"素纸灯","竹骨灯","红灯笼","鲤鱼灯","芙蓉花灯","如意宫灯","玲珑盏","玉兔盏","冰心盏","蟠龙","云鹤","风荷","金风玉露","凰火燎原","月露清愁","夭桃秾李","荒尘"}
	待选[17] = {"油纸伞","红罗伞","紫竹伞","锦绣椎","幽兰帐","琳琅盖","孔雀羽","金刚伞","落梅伞","鬼骨","云梦","枕霞","碧火琉璃","雪羽穿云","月影星痕","浮生归梦","晴雪"}
	待选[19] = {{"方巾","簪子"},{"布帽","玉钗",},{"面具","梅花簪子"},{"纶巾","珍珠头带"},{"缨络丝带","凤头钗"},{"羊角盔","媚狐头饰"},{"水晶帽","玉女发冠"},{"乾坤帽","魔女发冠"},{"黑魔冠","七彩花环"},{"白玉龙冠","凤翅金翎"},{"水晶夔帽","寒雉霜蚕"},{"翡翠曜冠","曜月嵌星"},{"金丝黑玉冠","郁金流苏簪"},{"白玉琉璃冠","玉翼附蝉翎"},{"兽鬼珐琅面","鸾羽九凤冠"},{"紫金磐龙冠","金珰紫焰冠"},{"浑天玄火盔","乾元鸣凤冕"}}
	待选[21] = {{"布裙","布衣"},{"丝绸长裙","皮衣"},{"五彩裙","鳞甲"},{"龙鳞羽衣","锁子甲"},{"天香披肩","紧身衣"},{"金缕羽衣","钢甲"},{"霓裳羽衣","夜魔披风"},{"流云素裙","龙骨甲"},{"七宝天衣","死亡斗篷"},{"飞天羽衣","神谕披风"},{"穰花翠裙","珊瑚玉衣"},{"金蚕丝裙","金蚕披风"},{"紫香金乌裙","乾坤护心甲"},{"碧霞彩云衣","蝉翼金丝甲"},{"金丝蝉翼衫","金丝鱼鳞甲"},{"五彩凤翅衣","紫金磐龙甲"},{"鎏金浣月衣","混元一气甲"}}
              待选[20] = {"护身符","五色飞石","珍珠链",{"骷髅吊坠","苍魂珠"},{"江湖夜雨","九宫坠"},{"荧光坠子","高速之星"},{"风月宝链","八卦坠"},{"碧水青龙","鬼牙攫魂"},{"万里卷云","疾风之铃"},"七彩玲珑","黄玉琉佩","鸾飞凤舞","衔珠金凤佩","七璜珠玉佩","鎏金点翠佩","紫金碧玺佩","落霞陨星坠"}
	待选[22] = {"腰带","缎带","银腰带",{"水晶腰带","玉树腰带"},{"琥珀腰链","白面狼牙"},{"乱牙咬","魔童大牙"},{"攫魂铃","双魂引"},{"兽王腰带","百窜云"},{"八卦锻带","圣王坠"},"幻彩玉带","珠翠玉环","金蟾含珠","乾坤紫玉带","琉璃寒玉带","蝉翼鱼佩带","磐龙凤翔带","紫霄云芒带"}
	待选[23] = {"布鞋","牛皮靴","马靴","侠客履","神行靴","绿靴","追星踏月","九州履","万里追云履","踏雪无痕","平步青云","追云逐电","乾坤天罡履","七星逐月靴","碧霞流云履","金丝逐日履","辟尘分光履"}

function 装备自选:初始化()
    __置窗口坐标(self)
    self.允许移动 = true
end

function 装备自选:打开(data,o)
    self:置可见(true)
	self.当前格子=o
    self.数据 = data   
	self.ansl = 2
	
    self:重置()
end

function 装备自选:重置()
    local item_mc = self:取名称(self.数据.名称,160)
	local dj
if item_mc ~= nil then
		dj = 取物品(item_mc)
		self.装备名称=item_mc
	    self.装备类型 =self:取装备类型(dj)
		print(self.装备类型)
    self.ansl = 2
    if self.装备类型 ~= "腰带自选礼包" and self.装备类型 ~= "头盔自选礼包" and self.装备类型 ~= "项链自选礼包" and self.装备类型 ~= "鞋子自选礼包" then
	    	ansl = 4
	    end
	for i=1,4 do
		if i <= self.ansl then
			装备自选["加"..i]:置可见(true)
		else
			装备自选["加"..i]:置可见(false)
		end
	end
end
	self:置图像(dj,item_mc)
	
end

function 装备自选:显示(x,y)
	字体18:显示(x+100,y+198,self.新增特技 or "未选择")
	字体18:显示(x+100,y+198+35,self.新增特效 or "未选择")
	if self.ansl >= 4 then
		字体18:显示(x+100,y+198+70,self.双加1 or "未选择")
		字体18:显示(x+100,y+198+105,self.双加2 or "未选择")
	end
end
function 装备自选:取装备类型(dj)
	local 类型
	if dj and dj[3] and dj[2]==2 then
		if dj[3]==1 then
			类型="头盔"
		elseif dj[3]==2 then
            类型="项链"	
		elseif dj[3]==3 then
            类型="武器"
		elseif dj[3]==4 then
            类型="衣服"	
		elseif dj[3]==5 then
            类型="腰带"	
		elseif dj[3]==6 then
            类型="鞋子"	
		end
		return 类型
	end 
end
function 装备自选:置图像(dj,mc)
	self.名称 = mc
if mc then
	self.装备类型 =self:取装备类型(取物品(mc))--__物品数据[mc].部位
	self.装备名称=mc
    self.ansl = 2
    if string.find(self.装备类型,"武器") or string.find(self.装备类型,"衣服") then
        self.ansl = 4
    end
	for i=1,4 do
		if i <= self.ansl then
			装备自选["加"..i]:置可见(true)
		else
			装备自选["加"..i]:置可见(false)
		end
	end
end
	local nsf = require('SDL.图像')(300,407)
    if nsf:渲染开始() then
		local lssj = 取输入背景(0, 0, 140, 23)
        置窗口背景("装备自选",0,12,300,380,true):显示(0,0)
        取灰色背景(0,0,290,340,true):显示(5,45)
		self.道具介绍:清空()
		if dj then
			__res:取图像(__res:取地址("shape/dj/", dj[13])):显示(10,50)
			self.道具介绍:置文本('#Y'..mc)
			self.道具介绍:置文本('#K'..dj[1])
			self.类型选择:置可见(false)
		else
			self.类型选择:置可见(true)
		end
		for i=1,4 do
			if i <= self.ansl then
				字体18:取图像(属性类型[i]):显示(30,195+((i-1)*35))
				lssj:显示(90,195+((i-1)*35))
			end
		end
    end
    self:置精灵(nsf:到精灵())
end


for i=1,4 do
	local 临时函数 = 装备自选:创建我的按钮(__res:getPNGCC(1,641,320,29,29),"加"..i,240,195+((i-1)*35))
	function 临时函数:左键弹起(x,y,msg)
		local 对话信息
		if i==1 then
			对话信息 = 可用特技
			local 回调处理 = function (i,选项)
				装备自选.新增特技 = 选项[i]
			end
			多开数据[当前].__UI界面.窗口层.对话栏:打开({模型="女人_万圣公主",名称="装备特技",对话="请选择装备的特技",选项=对话信息,回调处理=回调处理})
		elseif i==2 then
			对话信息 = 可用特效
			local 回调处理 = function (i,选项)
				装备自选.新增特效 = 选项[i]
			end
			多开数据[当前].__UI界面.窗口层.对话栏:打开({模型="女人_万圣公主",名称="装备特效",对话="请选择装备特效",选项=对话信息,回调处理=回调处理})
		elseif i==3 then
			对话信息 = 额外属性
			local 回调处理 = function (i,选项)
				if 装备自选.双加2 == 选项[i] then
					多开数据[当前].__UI弹出.提示框:打开('#Y无法选择相同得双加')
				else
					装备自选.双加1 = 选项[i]
				end
			end
			多开数据[当前].__UI界面.窗口层.对话栏:打开({模型="女人_万圣公主",名称="装备双加[1]",对话="请选择装备的双加[1]",选项=对话信息,回调处理=回调处理})
		elseif i==4 then
			对话信息 = 额外属性
			local 回调处理 = function (i,选项)
				if 装备自选.双加1 == 选项[i] then
					多开数据[当前].__UI弹出.提示框:打开('#Y无法选择相同得双加')
				else
					装备自选.双加2 = 选项[i]
				end
			end
			多开数据[当前].__UI界面.窗口层.对话栏:打开({模型="女人_万圣公主",名称="装备双加[2]",对话="请选择装备的双加[2]",选项=对话信息,回调处理=回调处理})
		end
	end
end

local 类型选择 = 装备自选:创建我的按钮(__res:getPNGCC(1,641,320,29,29),"类型选择",240,150)
function 类型选择:左键弹起(x,y,msg)
	local 对话信息 = 可选造型
	
	local 回调处理 = function (i,选项)
		local dj = 取物品(选项[i])
		装备自选:置图像(dj,选项[i])
	end
	多开数据[当前].__UI界面.窗口层.对话栏:打开({模型="女人_万圣公主",名称="造型选择",对话="请选择装备的造型",选项=对话信息,回调处理=回调处理})
end


local 关闭 = 装备自选:创建关闭按钮(__res:取地址('shape/ui/xinjia/',0X00000001), "关闭", 280, 13)
function 关闭:左键弹起(x,y,msg)
    装备自选:置可见(false)
end

local 确定 = 装备自选:创建我的按钮(__res:getPNGCC(1,449,28,174,35,true):置拉伸(90,30),"确定",180,340,"确定")

function 确定:左键弹起(消息,x,y)
    local 事件 = function()
		if 装备自选.装备名称==nil or 装备自选.新增特效==nil or 装备自选.当前格子==nil or 装备自选.新增特技==nil  then
			print(装备自选.装备名称)
			多开数据[当前].__UI弹出.提示框:打开('#Y请正确选取所有属性！')
			return
		end
		local 临时={}
		临时.特效=装备自选.新增特效
		临时.格子=装备自选.当前格子
		临时.名称=装备自选.装备名称
		临时.等级=装备自选.数据.等级 or 160
		临时.特技=装备自选.新增特技
		临时.双加2=装备自选.双加2
		临时.双加1=装备自选.双加1
		临时.道具名字=装备自选.数据.名称
		发送数据(多开数据.当前,3824,{标识=临时})
		装备自选.装备类型 =nil
		装备自选.装备名称 =nil
		装备自选.新增特效=nil
		装备自选.新增特技=nil
		装备自选.双加2=nil
		装备自选.双加1=nil
		 装备自选:置可见(false)
	end
	local wb = "属性一旦选定无法更改,你确定要提交么?"   
	多开数据[当前].__UI界面.窗口层.文本栏:打开(wb,285,155,390,200,事件)
end

local 道具介绍 = 装备自选:创建我的文本("道具介绍",130,60,160,220)

function 装备自选:取名称(名称,等级)
	local x等级 = math.floor(等级/10+1)
	if  名称=="武器自选礼包" then
		可选造型={}
		print(名称,等级,x等级)
		for i=1,18 do
			if 待选[i] then
			    for n=1,#待选[i] do
			    	if n==x等级 then
			    		table.insert(可选造型,待选[i][n])
			    	end
			    end
			end
		end
		可用特效={"无级别限制","珍宝","易修理","永不磨损","精致","必中","绝杀"}
		return nil
	elseif 名称=="衣服自选礼包" then
		可选造型={}
			if 待选[21] and 待选[21][x等级] then
				可选造型=待选[21][x等级]
			end
		可用特效={"无级别限制","珍宝","易修理","永不磨损","精致","专注","神农","再生"}
		return nil
	elseif 名称=="头盔自选礼包" then
		可选造型={}
			if 待选[19] and 待选[19][x等级] then
				可选造型=待选[19][x等级]
			end
		可用特效={"无级别限制","珍宝","易修理","永不磨损","精致","专注","神农","再生"}
		return nil
	elseif 名称=="项链自选礼包" then
		可选造型 = nil
		可用特效={"无级别限制","珍宝","易修理","永不磨损","精致","专注","再生"}
		return 待选[20][x等级]
	elseif 名称=="腰带自选礼包" then
		可选造型 = nil
		可用特效={"无级别限制","珍宝","易修理","永不磨损","精致","愤怒","暴怒","神农"}
		--可用特技={}
		return 待选[22][x等级]
	elseif 名称=="鞋子自选礼包" then
		可选造型 = nil
		可用特效={"无级别限制","珍宝","易修理","永不磨损","精致","专注","神农","再生"}
		return 待选[23][x等级]
	end
end
